package com.bolang.onlycode.demo.designPatterns.observe;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体被观察者：微信公众号
 */
public class SubscriptionSubject implements Subject {
    private List<Observer> weixinuserList = new ArrayList<Observer>();

    @Override
    public void attach(Observer observer) {
        weixinuserList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        weixinuserList.remove(observer);
    }

    @Override
    public void notify(String msg) {
        for (Observer observer : weixinuserList) {
            observer.update(msg);
        }
    }
}
